 version 18
 
 **************** STUDY 1 **************************
 cd ".\Study 1"
 
 import delimited "s1.csv", clear
 
 drop if race != 1
 gen incomeR = (12-income)/11
 gen female = 0
 replace female =1 if gender ==1
 gen ageR = (age-18)/65
 gen edR = (ed-1)/5
 gen college = 1 if ed >= 4
 replace college = 0 if ed <4
 replace religiosity = "0" if religiosity =="NA"
 encode religiosity, gen(nreligiosity)
 gen religR = (nreligiosity)/6
 gen voter = 2- vote_reg
 encode condition, gen(ncondition)
 
 label var incomeR "Income"
 label var college "College"
 label var female "Female"
 label var pid7 "Party ID"
 label var placement "Placement"
 label var condition "Condition"
 label var ncondition "Condition"
 label var age "Age"
 label var ageR "Age"
 label var voter"Voter"
 label var religR "Religiosity"
 

 cd "..\Tables"
estpost summarize incomeR college age female pid7 voter
esttab using summary_s1.tex, cells("count mean sd min max") label noobs replace 

orth_out incomeR college ageR female pid7 voter using balance_s1.tex, by(ncondition) se pcompare latex replace


********************* STUDY 2 *****************************
cd "..\Study 2"

 import delimited "s2.csv", clear
 
 encode income, gen(nincome)
 gen incomeR = 2-nincome
 encode gender, gen(ngender)
 gen female = 2-ngender
 encode age, gen(nage)
 gen ageR = (nage-1)/3
 encode education, gen(neducation)
 gen college = neducation
 replace college = 0 if neducation !=1
 *gen voter = 2- vote_reg
 encode placement, gen(nplacement)
 replace pid5 = "." if pid5=="NA"
 encode pid5, gen(pidR)
 
 label var incomeR "Income"
 label var college "College"
 label var female "Female"
 label var pidR "Party ID"
 label var nplacement "Condition"
 label var ageR "Age"
* label var voter"Voter"

 sort respondent
 by respondent: gen dup = cond(_N==1,0,_n)
 drop if dup>1
 

 cd "..\Tables"
estpost summarize incomeR college ageR female pidR
esttab using summary_s2.tex, cells("count mean sd min max") label noobs replace 

orth_out incomeR college ageR female pidR using balance_s2.tex, by(nplacement) se pcompare latex replace


********************* STUDY 2 *****************************
cd "..\Study 4"

 import delimited "s4_dat.csv", clear
 
 sort subject
 by subject: gen dup = cond(_N==1,0,_n)
 drop if dup>1
 drop female
 
replace gender = "." if gender =="NA"
encode gender, gen(female)
replace partyid = "." if partyid=="NA"
encode partyid, gen(pid)
replace age_response = "." if age_response =="NA"
encode age_response, gen(age_response2)
replace age2 = "." if age2=="NA"
encode age2, gen(ageR)

replace income_response = "." if income_response=="NA"
encode income_response, gen(incomeR)
encode election_condition, gen(condition)

replace ideology ="." if ideology=="NA"
encode ideology, gen(ideologyR)

 label var incomeR "Income"
 label var female "Female"
 label var pid "Party ID"
 label var condition "Condition"
 label var ageR "Age"
 label var age_response2 "Age"
 label var ideologyR "Ideology"
 
  cd "..\Tables"
 estpost summarize incomeR age_response2 female pid ideologyR
 esttab using summary_s4.tex, cells("count mean sd min max") label noobs replace 

 orth_out incomeR ageR female pid ideologyR using balance_s4.tex, by(condition) se pcompare latex replace


